<!doctype html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>购物车</title>
    <link rel="stylesheet" href="/static/lyCart/css/reset(1).css" th:href="@{/lyCart/css/reset(1).css}">
    <link rel="stylesheet" href="/static/lyCart/css/carts.css" th:href="@{/lyCart/css/carts.css}">
    <link rel="stylesheet" href="/static/dist/css/cart.css" th:href="@{/dist/css/cart.css}">
    <link rel="stylesheet" href="/static/dist/css/reset.css" th:href="@{/dist/css/reset.css}" >
    <link rel="stylesheet" href="/static/dist/font/iconfont.css" th:href="@{/dist/font/iconfont.css}">
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<div class="menu">
    <div class="menu-cen">
        <span class="iconfont icon-index"></span>
        <a href="/tmall/index">天猫首页</a>
        <p>喵，欢迎来天猫国际</p>
        <i id="tui"><a href="login.html" id="ming">请登录</a></i>
        <ul class="menu-you">
            <li class="yi"><a>我的淘宝</a>
                <div>
                    <a href="">已买到的宝贝</a>
                    <a href="">已卖出的宝贝</a>
                </div>
            </li>
            <li>
                <span class="iconfont icon-gouwuche"><a href="">购物车</a></span>
            </li>
            <li class="yi"><a href="">收藏夹</a>
                <div>
                    <a href="">收藏的宝贝</a><br>
                    <a href="">收藏的店铺</a>
                </div>
            </li>
            <li class="san">
                <span class="iconfont icon-icon1460357101473"><a href="">手机版</a></span>
                <div>
                    <img src="../img/soujima.png" alt="">
                </div>
            </li>
            <li><a href="">淘宝网</a></li>
            <li class="er"><a>商家支持</a>
                <div>
                    <ul>
                        <li>
                            <h3>商家：</h3>
                            <a href="">商家中心</a>
                            <a href="">天猫规则</a>
                            <a href="">商家入驻</a>
                            <a href="">运营服务</a>
                            <a href="">商家工具</a>
                            <a href="">商家规则</a>
                            <a href="">天猫智库</a>
                            <a href="">喵言喵语</a>
                        </li>
                        <li>
                            <h3>帮助：</h3>
                            <a href="">帮助中心</a>
                        </li>
                    </ul>
                </div>
            </li>
            <li class="si">
                <span class="iconfont icon-liebiao"><a href="">网站导航</a></span>
                <div class="si-da">
                    <div class="yi">
                        <h2>热点推荐 Hot</h2>
                        <ul>
                            <li><a href="">天猫超市</a></li>
                            <li><a href="">喵鲜生</a></li>
                            <li><a href="">天猫超市</a></li>
                            <li><a href="">天猫超市</a></li>
                            <li><a href="">喵鲜生</a></li>
                            <li><a href="">天猫超市</a></li>
                            <li><a href="">喵鲜生</a></li>
                            <li><a href="">天猫超市</a></li>
                            <li><a href="">喵鲜生</a></li>
                            <li><a href="">天猫超市</a></li>
                            <li><a href="">天猫超市</a></li>
                            <li><a href="">天猫超市</a></li>
                            <li><a href="">天猫超市</a></li>
                            <li><a href="">天猫超市</a></li>
                        </ul>
                    </div>
                    <div class="er">
                        <h2>行业市场 Market</h2>
                        <ul>
                            <li><a href="">美妆</a></li>
                            <li><a href="">美妆</a></li>
                            <li><a href="">美妆</a></li>
                            <li><a href="">美妆</a></li>
                            <li><a href="">美妆</a></li>
                            <li><a href="">美妆</a></li>
                            <li><a href="">美妆</a></li>
                            <li><a href="">美妆</a></li>
                            <li><a href="">美妆</a></li>
                            <li><a href="">美妆</a></li>
                            <li><a href="">美妆</a></li>
                            <li><a href="">美妆</a></li>
                            <li><a href="">美妆</a></li>
                            <li><a href="">美妆</a></li>
                            <li><a href="">美妆</a></li>
                            <li><a href="">美妆</a></li>
                        </ul>
                    </div>
                    <div class="san">
                        <h2>品牌风尚 Brand</h2>
                        <ul>
                            <li><a href="">美妆</a></li>
                            <li><a href="">美妆</a></li>
                            <li><a href="">美妆</a></li>
                            <li><a href="">美妆</a></li>
                            <li><a href="">美妆</a></li>
                            <li><a href="">美妆</a></li>
                        </ul>
                    </div>
                    <div class="si">
                        <h2>服务指南 Help</h2>
                        <ul>
                            <li><a href="">天猫国际规则 </a></li>
                            <li><a href="">海外正品 </a></li>
                            <li><a href="">七天放心退 </a></li>
                            <li><a href="">商标代理 </a></li>
                            <li><a href="">帮助中心</a></li>
                        </ul>
                    </div>
                </div>
            </li>
        </ul>
    </div>
</div>
<section class="cartMain">
    <div class="cartMain_hd">
        <ul class="order_lists cartTop" >
            <li class="list_chk">
                <!--所有商品全选-->
                <input type="checkbox" id="all" class="whole_check">
                <label for="all"></label>
                全选
            </li>
            <li class="list_con">商品信息</li>
            <li class="list_info">商品参数</li>
            <li class="list_price">单价</li>
            <li class="list_amount">数量</li>
            <li class="list_sum">金额</li>
            <li class="list_op">操作</li>
        </ul>
    </div>
<div th:each="y:${list2}">
    <div class="cartBox" >
        <div class="shop_info">
            <div class="all_check">
                <!--店铺全选-->
                <input type="checkbox" th:id="${y.id}+'e'" class="shopChoice">
                <label th:for="${y.id}+'e'" class="shop"></label>
            </div>
            <div class="shop_name">
                店铺：<a href="javascript:;" th:text="${y.name}"></a>
            </div>
        </div>
        <div class="order_content">
            <tr th:each="x:${list}" >

            <ul class="order_lists" th:if="${y.name}==${x.products.seller}">
                <li class="list_chk">
                    <input type="checkbox" th:id="${x.productId}+${y.id}+1" name="ddd" class="son_check" th:value="${x.productId}">
                    <label th:for="${x.productId}+${y.id}+1"></label>
                </li>
                <li class="list_con">
                    <div class="list_img"><a href="javascript:;"><img  th:src="@{/lyCart/images/1.png}" alt=""></a></div>
                    <div class="list_text"><a href="javascript:;" th:text="${x.products.subTitle}"></a></div>
                </li>
                <li class="list_info">
                    <p>规格：默认</p>
                    <p>尺寸：16*16*3(cm)</p>
                </li>
                <li class="list_price">
                    <p class="price" th:text="'￥'+${x.products.promotePrice}"></p>
                </li>
                <li class="list_amount">
                    <div class="amount_box">
                        <a href="javascript:;" class="reduce reSty">-</a>
                        <input type="text" value="1" class="sum">
                        <a href="javascript:;" class="plus">+</a>
                    </div>
                </li>
                <li class="list_sum">
                    <p class="sum_price" th:text="'￥'+${x.products.promotePrice}"></p>
                </li>
                <li class="list_op">
                    <p class="del"><a href="javascript:;" class="delBtn" onclick="deleteOne(this)">移除商品</a></p>
                </li>
<!--                <p hidden="hidden" th:text="${x.products.id}"></p>-->
            </ul>
            </tr>
        </div>
    </div>
</div>


    <!--底部-->
    <div class="bar-wrapper">
        <div class="bar-right">
            <div class="piece">已选商品<strong class="piece_num">0</strong>件</div>
            <div class="totalMoney">共计: <strong class="total_text" id="total">0.00</strong></div>
            <div class="calBtn"><a href="javascript:;" onclick="total2()">结算</a></div>
        </div>
    </div>
</section>
<section class="model_bg"></section>
<section class="my_model">
    <p class="title">删除宝贝<span class="closeModel">X</span></p>
    <p>您确认要删除该宝贝吗？</p>
    <div class="opBtn"><a href="javascript:;" class="dialog-sure">确定</a><a href="javascript:;" class="dialog-close">关闭</a></div>
</section>
<script src="/static/lyCart/js/jquery-1.11.0.min.js" th:src="@{/lyCart/js/jquery-1.11.0.min.js}"></script>
<script src="/static/lyCart/js/carts.js" th:src="@{/lyCart/js/carts.js}"></script>
<script>
    function total2() {
        var  $sonCheckBox = $('.son_check');
        var   $shopCheckbox = $('.shopChoice');
        var   $cartBox = $('.cartBox');
        var oneTotal = '';//单独一个产品的数量和总价
        var oneNumber = '';
        var total_money = 0;//总共的数量，价钱
        var total_count = 0;
        var calBtn = $('.calBtn a');
        $sonCheckBox.each(function () {
            if ($(this).is(':checked')) {
                var goods = parseInt($(this).parents('.order_lists').find('.sum_price').html().substring(1));
                var num =  parseInt($(this).parents('.order_lists').find('.sum').val());
                oneTotal+=goods+',';
                oneNumber+=num+',';
                total_money += goods;
                total_count += num;
            }
        });

        // alert(total_money);
        // alert( total_count);
        // console.log("总的"+total_money)
        // console.log("总的"+total_count)
        // console.log("单的"+oneTotal)
        // console.log("单的"+oneNumber)
       var obj = document.getElementsByName("ddd");
       var check_val = [];
        for( var k in obj){
            if(obj[k].checked)
                check_val.push(obj[k].value);
        }
       // alert(check_val.constructor);//得到
        window.location.href="order?oneTotal="+oneTotal+"&oneNumber="+oneNumber+
            "&total_money="+total_money+"&total_count="+total_count+"&check_val="+check_val;
        // $.ajax({
        //     url:"/tmall/oderItem",
        //     type:"post",
        //     dataType:"json",
        //     traditional: true,
        //     data:{"oneTotal":oneTotal,"oneNumber":oneNumber,"total_money":total_money,"total_count":total_count,"check_val":check_val},
        //     success:function (result) {
        //         if(result.code=="添加成功"){
        //
        //         }else {
        //             alert("失败");
        //         }
        //
        //     },
        //     error:function (err) {
        //       alert("请求失败")
        //     },
        //
        // });
    }
    function deleteOne(obj) {
        var userID=$(obj).parents("ul").find("li").eq(0).find("input").val();
        console.log(userID);
        $.ajax({
            url:"/tmall/cartDelete",
            type:"post",
            dataType:"json",
            traditional: true,
            data:{"userId":userID},
            success:function (result) {
                console.log(result.code);

            },
            error:function (err) {
                layer.msg('ajax请求失败!',{icon: 5,time:1000});
            },

        });
    }
</script>
</body>
</html>